import * as Types from "../../types";

export function isJsonObject(obj: any): obj is Types.JsonObject {
    return typeof obj === "object"
        && obj.constructor !== undefined
        && obj.constructor === Object;
}

export function isStringWithNotEmpty(obj: any): obj is string {
    return typeof obj === "string"
        && obj.trim().length > 0;
}

export function isElement(obj: any): obj is Element {
    return typeof obj === "object"
        && obj instanceof Element;
}

export function isStringOrElement(obj: any): obj is string | Element {
    return typeof obj === "string" || isElement(obj);
}

export function isMoveEvent(obj: any): obj is MouseEvent {
    return obj.button !== undefined
        && obj.touches === undefined;
}